package com.example.amtf_tmdrecycle;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class edititemActivity extends AppCompatActivity {

    Button edit_btn;

    EditText edit_progress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edititem);

        edit_btn=findViewById(R.id.edit_button);
        edit_progress=findViewById(R.id.edit_progress);

        edit_btn.setOnClickListener(new View.OnClickListener() {              //按下修改按钮   判断进度输入合法后传回主界面
            @Override
            public void onClick(View v) {
                int temp = Integer.parseInt(edit_progress.getText().toString());
                if (temp >= 1 && temp <= 100) {
                    Intent intent = new Intent();
                    intent.putExtra("currentPro", temp + "");
                    setResult(RESULT_OK, intent);
                    finish();
                } else {
                    Toast.makeText(edititemActivity.this, "输入数据非法", Toast.LENGTH_SHORT).show();
                    edit_progress.setText("");
                    edit_progress.setFocusable(true);
                }
            }
        });
    }
}
